<!DOCTYPE html>
<html lang="en" xmlns:http="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="bootstrap/css/bootstrap.min.css"></script>
    <script type="text/javascript" src="bootstrap/js/bootstrap.min.js"></script>
    <title>Title</title>
</head>
<body>

<div class="jumbotron" style="background-image: url(img/star.jpg);background-repeat: no-repeat;background-size: cover;">
        <div class="container" style="text-align: center">
            <h1><strong><font color="white">优课达会议室智能管理系统</font></strong></h1>    
            <h3><font color="white">更快速、更人性化的会议室解决方案</font></h3>       
        </div>
</div>
<div style="text-align: center;">
    <form class="bs-example bs-example-form" role="form">
        <div class="input-group input-group-lg">
            <span class="input-group-addon">请输入会议室号</span>
            <input  id="code" type="text" class="form-control">
        </div>
        <br>
        <div class="input-group input-group-lg">
            <span class="input-group-addon" >请输入会议室人数</span>
            <input id="capacities" type="text" class="form-control">
        </div>
        <br>
        <button type="button" id="check" class="btn btn-primary btn-lg" onclick="f()">确定</button>
    </form>
</div>

</body>

<script type="text/javascript">

    var code = $("#code").val;
    var capacities = $("#capacities").val;

    console.log(code);
    console.log(capacities);


    function f() {

        var code = $("#code").val();
        var capacities = $("#capacities").val();

        var pattern = /(10|[1-9])-(10|[1-9])-(10|[1-9])$/;

        if (capacities == null || capacities == undefined || capacities == ''){
            alert("请重新输入会议室人数");
            return;
        }

        if (pattern.test(code)){

            $.ajax({
                url:"/compute",
                type:'post',
                data:{
                    code:code,
                    capacities:capacities
                },
                success:function (data) {
                    /* alert("会议室号为："+data.data);
                     window.location.href="head.html"*/
                    if (data.status === '成功'){
                        alert("系统为您推荐的会议室:"+data.data);
                        window.location.href="head.html"
                    }
                },
                error:function () {

                }
            })
        } else {
            alert("请输入正确会议室号");
            return;
        }


        console.log(code);
        console.log(capacities);

        // $.ajax({
        //     url:"/compute",
        //     type:'post',
        //     data:{
        //         code:code,
        //         capacities:capacities
        //     },
        //     success:function (data) {
        //         /* alert("会议室号为："+data.data);
        //          window.location.href="head.html"*/
        //            if (data.status === '成功'){
        //                  alert("会议室号为："+data.data);
        //                  window.location.href="head.html"
        //              }
        //     },
        //     error:function () {
        //
        //     }
        // })
    }


</script>
</html>